﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DataList.aspx.cs" Inherits="Mdbw_DataList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="style/default.css" rel="stylesheet" type="text/css" />

    <script src="js/jquery-1.4.4.min.js" type="text/javascript"></script>

    <script src="lhgdialog/lhgdialog.min.js" type="text/javascript"></script>

    <script type="text/javascript">
        $(document).ready(function()
        {
            var selobj = null;
            var selobjcolor = null;
            $(".trnei,.lupai").each(function()
            {
                $(this).click(function()
                {
                    try
                    {
                        selobj.css("background-color", selobjcolor);
                    }
                    catch (ex)
                    {
                    }
                    selobjcolor = $(this).css("background-color");
                    $(this).css("background-color", "#D1F880");
                    selobj = $(this);
                });
                $(this).find("td").dblclick(function()
                {
                    var col = $("#gvList").find(".lup").find("th")[$(this).index()];
                    var colname = $(col).text();
                    var type = "";
                    if ($(this).text() == "详情")
                    {
                        type = "text";
                    }
                    var tbname = "<%=Request.QueryString["tablename"] %>";
                    var pk = $("#hidPk").val(); //主键
                    var pkcol = "";
                    $("#gvList").find(".lup").find("th").each(function()
                    {
                        if ($(this).text().toLocaleLowerCase() == pk)
                        {
                            pkcol = $(this).index();
                            return false;
                        }
                    });
                    var pkvalue = $(this).parent().find("td:eq(" + pkcol + ")").text();                             
                    // alert($(pkcol).index());
                   
                    $.UpdateData(tbname, colname, type,pk,pkvalue);
                });

                //                $(this).dblclick(function()
                //                {                    
                //                    var tbname = "<%=Request.QueryString["tablename"] %>";
                //                    var colname = "";
                //                    var type="";//字段类型
                //                    
                //                    //$.UpdateData(tbname, colname);
                //                });
            });
            jQuery.UpdateData = function(tbname, colname, type,pk,pkvalue)
            {
                var dg;
                if (type == "text")
                {
                    dg = new $.dialog({ cover: true, bgcolor: '#000', opacity: 0.3, id: "editcol", maxBtn: false, title: "修改数据,字段为" + colname, page: "EditBigData.aspx?tbname=" + tbname + "&colname=" + colname + "&pk="+pk+"&pkvalue="+pkvalue+"&" + Math.random(), width: 600, height: 500 });
                }
                else
                {
                    dg = new $.dialog({ cover: true, bgcolor: '#000', opacity: 0.3, id: "editcol", maxBtn: false, title: "修改数据,字段为" + colname, page: "EditData.aspx?tbname=" + tbname + "&colname=" + colname + "&pk="+pk+"&pkvalue="+pkvalue+"&" + Math.random(), width: 350, height: 200 });
                }
                dg.ShowDialog();
            }
        });
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div class="nav" style="padding: 5px;">
        当前位置：<a style="color: White;" href="Default.aspx">数据表</a> ＞<%=Request.QueryString["tablename"] %>
    </div>
    <asp:GridView ID="gvList" runat="server" AutoGenerateColumns="true" AllowPaging="true"
        SkinID="gvcustomer" PageSize="20" AllowSorting="True" ShowHeader="true" OnPageIndexChanged="gvList_PageIndexChanged"
        OnPageIndexChanging="gvList_PageIndexChanging" OnRowCommand="gvList_RowCommand"
        AutoGenerateDeleteButton="true" OnRowDeleting="gvList_RowDeleting">
        <Columns>
        </Columns>
    </asp:GridView>
    <input type="hidden" id="hidPk" runat="server" />
    </form>
</body>
</html>
